﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for MapControl
/// </summary>
public class MapControl
{
	public MapControl()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public static bool TrackPoint(string title, string description, string image, double latitude, double longitude, int userid) 
    {
        try
        {
            SqlConnection conn = MapConnection.GetConnection();
            string sqlInsert = "INSERT INTO places(title,description,image,latitude,longitude,userid) VALUES (@title,@description,@image,@latitude,@longitude,@userid)";
            SqlCommand command = new SqlCommand(sqlInsert,conn);
            command.Parameters.AddWithValue("@title",title);
            command.Parameters.AddWithValue("@description",description);
            command.Parameters.AddWithValue("@image",image);
            command.Parameters.AddWithValue("@latitude", latitude);
            command.Parameters.AddWithValue("@longitude",longitude);
            command.Parameters.AddWithValue("@userid", userid);

            command.ExecuteNonQuery();

            MapConnection.CloseConnetion(conn);
            return true;
        }
        catch (Exception)
        {
            return false;
        }
    }
}